package org.wtfbbq.net.wifi;

import java.util.Stack;

/**
 *
 *
 */
public class WirelessNetwork {
	
	private String ssid, networkType, authentication, encryption;
	private Stack<AccessPoint> aps = new Stack<AccessPoint>();
	
	public WirelessNetwork (
		String ssid,
		String networkType,
		String authentication,
		String encryption )
	{
		this.ssid = ssid;
		this.networkType = networkType;
		this.authentication = authentication;
		this.encryption = encryption;
	}
	
	public WirelessNetwork ( ) {
		// empty
	}
	
	public void setSSID ( String ssid ) {
		this.ssid = ssid;
	}
	
	public void setNetworkType ( String networkType ) {
		this.networkType = networkType;
	}
	
	public void setAuthentication ( String authentication ) {
		this.authentication = authentication;
	}
	
	public void setEncryption ( String encryption ) {
		this.encryption = encryption;
	}
	
	public String getSSID ( ) {
		return ssid;
	}
	
	public String getNetworkType ( ) {
		return networkType;
	}
	
	public String getAuthentication ( ) {
		return authentication;
	}
	
	public String getEnryption ( ) {
		return encryption;
	}
	
	public void addAccessPoint ( AccessPoint ap ) {
		aps.push(ap);
	}
	
	public void removeAccessPoint ( AccessPoint ap ) {
		aps.remove(ap);
	}
	
	public AccessPoint[] getAccessPoints ( ) {
		return (aps.toArray(new AccessPoint[aps.size()]));
	}
	
	public AccessPoint getAccessPoint ( ) {
		return aps.peek();
	}
	
	public AccessPoint getAccessPoint ( String bssid ) {
		for ( int i = 0 ; i < aps.size() ; i++ ) {
			if ( aps.get(i).getBSSID().equals(bssid) ) {
				return aps.get(i);
			}
		}
		return null;
	}
	
	public String toString ( ) {
		String s = "";
		s += "SSID: " + ssid + "\r\n";
		s += "Network type: " + networkType + "\r\n";
		s += "Authentication: " + authentication + "\r\n";
		s += "Encryption: " + encryption + "\r\n";
		s += "\r\nAccesspoints[" + aps.size() + "]\r\n";
		
		for ( int i = 0 ; i < aps.size() ; i++ ) {
			s += aps.get(i).toString() + "\r\n";
		}
		
		return s;
	
	}
}